﻿using System;
using ConsoleApp.Job.TaskFramework;
using ConsoleApp.Rmq;
using ConsoleAppFramework.Util;

namespace ConsoleAppFramework.Job.TaskJob.队列消费
{
    public class 线上飞书消息消费任务 : TaskBase
    {
        public override void Execute()
        {
            while (true)
            {
                new 线上飞书消息消费_RMQ(RmqQueueManager.QueueName.线上飞书消息).Start();
            }
        }

        public class 线上飞书消息消费_RMQ : ConsumerWorkerBase<FeiShuGroupMsg>
        {
            public 线上飞书消息消费_RMQ(string queueName)
            {
                Console.Title = queueName;
                QueueName = queueName;
            }

            protected override bool HandleComingMessage(FeiShuGroupMsg feiShuGroupMsg)
            {
                FeiShuMsgHelper.SendGroupMsg(feiShuGroupMsg.FeiShuGroupEnum, feiShuGroupMsg.Content);
                ConsoleHelper.WriteWarningLine(feiShuGroupMsg.Content);
                return true;
            }
        }
    }
}
